/**
 * Created by swing on 2017/5/28.
 */


//清空文本框内容
var clearForm = function (form) {
    // input清空
    $(':input', form).each(function () {
        var type = this.type;
        var tag = this.tagName.toLowerCase(); // normalize case
        if (type == 'text' || type == 'password' || type == 'number' || tag == 'textarea')
            this.value = "";
        // 多选checkboxes清空
        else if(type == 'radio')
            // this.removeAttribute("checked")
            $(this).attr('checked',false)
        // select 下拉框清空
        else if (tag == 'select')
            this.selectedIndex = 0;
    });
};

module.exports = clearForm